package Thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2023-01-09
 * Time: 23:21
 */
public class Thread11 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            while (true){
                System.out.println("Hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        System.out.println("join之前");
        t.start();
        //此处的join就是让当前main线程来等待t线程执行结束(等待t的run执行完)
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("join之后");
        while (true){
            System.out.println("Hello");
            Thread.sleep(1000);
        }
    }
}
